<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script src="./vue.js"></script>

    <style>
        .header {
            height: 40px;
            background-color: red;
            text-align: center;
        }
    </style>
</head>

<body>
    <div id="app">

        <com1></com1>





        <h1> 组件的最大特性就是复用性，而用好插槽能大大提高组件的可复用能力</h1>

        <com1>

            <div slot='header'> 头部 导航</div>

            <div> 中间主体内容</div>

            <div slot='footer'> 底部 导航</div>
        </com1>
        <hr>



    </div>



    <template id='com1'>
        <div>
            <h1> {{msg}}</h1>

            <header  class="header">

                <slot name='header'>

                </slot>

            </header>

            <main>

                <slot> </slot>

            </main>
            <footer>

                <slot name='footer'>

                </slot>
            </footer>

        </div>
    </template>

    <script>
        let com1 = {
            template: '#com1',
            data() {
                return {
                    msg: 'com1 组件'
                }
            }
        }


        //创建Vue实例,得到 ViewModel
        var vm = new Vue({
            el: '#app',
            data: {},
            methods: {},
            components: {
                com1
            }
        });
    </script>
</body>

</html>